package bigoo.common;

import bigoo.common.communication.Message;

public class PeerInfo {
	protected String peerID;
	protected String address;
	protected int port;

	public PeerInfo(String peerID, String address, int port) {
		this.peerID = peerID;
		this.address = address;
		this.port = port;
	}

	public String getPeerID() {
		return peerID;
	}

	public String getAddress() {
		return address;
	}

	public int getPort() {
		return port;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((peerID == null) ? 0 : peerID.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PeerInfo other = (PeerInfo) obj;
		if (peerID == null) {
			if (other.peerID != null)
				return false;
		} else if (!peerID.equals(other.peerID))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return peerID+Message.PARAM_SEPARATOR+address+Message.PARAM_SEPARATOR+port;
	}
}